package net.lzzy.arraylist2;

import javax.sound.midi.Soundbank;
import java.util.*;

public class TestCollection {
        public static void main(String[] args){
//            ArrayList<String> collection1=new ArrayList<>();
//            collection1.add("New York");
//            collection1.add("Atlanta");
//            collection1.add("Dallas");
//            collection1.add("'Madison");

            Student s1 = new Student("张三","大数据1班",90);
            Student s2 = new Student("李四","大数据1班",91);
            Student s3 = new Student("王五","大数据2班",94);
            Student s4 = new Student("赵六","大数据2班",80);
            Collection<Student> student = new ArrayList<>();
            student.add(s1);
            student.add(s2);
            student.add(s3);
            student.add(s4);

            Iterator<Student> iterator = student.iterator();
            while (iterator.hasNext()){
                System.out.println(iterator.next()+" ");
                if (iterator.hasNext()==false) {
                    for(Student stu:student){
                        if (stu.getClassname().equals("大数据1班")){
                            stu.setScore(stu.getScore()+10);
                            }
                        if(stu.getScore()>100){
                            stu.setScore(100);
                        }
                    }
                    System.out.println();
                    iterator = student.iterator();
                    while (iterator.hasNext()) {
                        System.out.println(iterator.next() + " ");
                    }
                }
            }


//            System.out.println("A list of cities in collection1:");
//            System.out.println(collection1);
//
//            System.out.println("\nIs Dallas in collectionl? "
//                    + collection1.contains("Dallas"));
//
//            collection1.remove("Dallas");
//            System.out.println("\n" + collection1.size()+
//                    "cities are in collectionl now");
//
//            Collection<String> collection2 = new ArrayList<>();
//            collection2.add("Seattle");
//            collection2.add("Portland");
//            collection2.add("Los Angeles");
//            collection2.add("Atlanta");
//
//            System.out.println("\nA list of cities in collection2:");
//            System.out.println(collection2);
//
//            ArrayList<String> c1 = (ArrayList<String>)(collection1.clone());
//            c1.addAll(collection2);
//            System.out.println("\nCities in collectionl or collection2: ");
//            System.out.println(c1);
//
//            c1=(ArrayList<String>)(collection1.clone());
//            c1.retainAll(collection2);
//            System.out.print("\nCities in collectionl and collection2;");
//            System.out.println(c1);
//
//            c1=(ArrayList<String>)(collection1.clone());
//            c1.removeAll(collection2);
//            System.out.print("\nCities in collectionl,but not in 2:");
//            System.out.println(c1);

        }
    }